﻿namespace Sidvall.FileSystemManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class SearchConfig : global::Sidvall.FileSystemManager.UI.Entities.Core.BusinessBase, global::Sidvall.FileSystemManager.Data.ISearchConfig
    {
        #region Business Members

        #region CaseSensitive

        private bool _CaseSensitive = false;
        partial void OnBeforeCaseSensitivePropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeCaseSensitivePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCaseSensitivePropertyChanged();
        public bool CaseSensitive
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_CaseSensitive);
                OnBeforeCaseSensitivePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CaseSensitive);
                OnBeforeCaseSensitivePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CaseSensitive", eventData.Value, true, true, true);
                    OnAfterCaseSensitivePropertyChanged();
                }
            }
        }

        #endregion
        #region FileSearchPatterns

        private string _FileSearchPatterns = string.Empty;
        partial void OnBeforeFileSearchPatternsPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeFileSearchPatternsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFileSearchPatternsPropertyChanged();
        public string FileSearchPatterns
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_FileSearchPatterns);
                OnBeforeFileSearchPatternsPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FileSearchPatterns);
                OnBeforeFileSearchPatternsPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("FileSearchPatterns", eventData.Value, true, true, true);
                    OnAfterFileSearchPatternsPropertyChanged();
                }
            }
        }

        #endregion
        #region FolderPath

        private string _FolderPath = string.Empty;
        partial void OnBeforeFolderPathPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeFolderPathPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFolderPathPropertyChanged();
        public string FolderPath
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_FolderPath);
                OnBeforeFolderPathPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FolderPath);
                OnBeforeFolderPathPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("FolderPath", eventData.Value, true, true, true);
                    OnAfterFolderPathPropertyChanged();
                }
            }
        }

        #endregion
        #region LoadDetails

        private bool _LoadDetails = false;
        partial void OnBeforeLoadDetailsPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeLoadDetailsPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterLoadDetailsPropertyChanged();
        public bool LoadDetails
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_LoadDetails);
                OnBeforeLoadDetailsPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _LoadDetails);
                OnBeforeLoadDetailsPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("LoadDetails", eventData.Value, true, true, true);
                    OnAfterLoadDetailsPropertyChanged();
                }
            }
        }

        #endregion
        #region SearchConfigId

        private System.Nullable<int> _SearchConfigId = null;
        partial void OnBeforeSearchConfigIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData);
        partial void OnBeforeSearchConfigIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterSearchConfigIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<int> SearchConfigId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<int>>(_SearchConfigId);
                OnBeforeSearchConfigIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _SearchConfigId);
                OnBeforeSearchConfigIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SearchConfigId", eventData.Value, true, true, true);
                    OnAfterSearchConfigIdPropertyChanged();
                }
            }
        }

        #endregion
        #region SearchFileContent

        private bool _SearchFileContent = false;
        partial void OnBeforeSearchFileContentPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeSearchFileContentPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFileContentPropertyChanged();
        public bool SearchFileContent
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_SearchFileContent);
                OnBeforeSearchFileContentPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFileContent);
                OnBeforeSearchFileContentPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SearchFileContent", eventData.Value, true, true, true);
                    OnAfterSearchFileContentPropertyChanged();
                }
            }
        }

        #endregion
        #region SearchFileName

        private bool _SearchFileName = false;
        partial void OnBeforeSearchFileNamePropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeSearchFileNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFileNamePropertyChanged();
        public bool SearchFileName
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_SearchFileName);
                OnBeforeSearchFileNamePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFileName);
                OnBeforeSearchFileNamePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SearchFileName", eventData.Value, true, true, true);
                    OnAfterSearchFileNamePropertyChanged();
                }
            }
        }

        #endregion
        #region SearchFolderName

        private bool _SearchFolderName = false;
        partial void OnBeforeSearchFolderNamePropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeSearchFolderNamePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterSearchFolderNamePropertyChanged();
        public bool SearchFolderName
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_SearchFolderName);
                OnBeforeSearchFolderNamePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _SearchFolderName);
                OnBeforeSearchFolderNamePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SearchFolderName", eventData.Value, true, true, true);
                    OnAfterSearchFolderNamePropertyChanged();
                }
            }
        }

        #endregion
        #region SearchPatterns

        private string _SearchPatterns = string.Empty;
        partial void OnBeforeSearchPatternsPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeSearchPatternsPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterSearchPatternsPropertyChanged();
        public string SearchPatterns
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_SearchPatterns);
                OnBeforeSearchPatternsPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _SearchPatterns);
                OnBeforeSearchPatternsPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("SearchPatterns", eventData.Value, true, true, true);
                    OnAfterSearchPatternsPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.GetKey(this);
            }
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.AcceptChanges(this);
        }

        #endregion
        #region Copy

        public SearchConfig Copy()
        {
            return Copy(null);
        }
        partial void OnAfterCopy(SearchConfig destination, Sidvall.Data.CopySettings settings);
        public SearchConfig Copy(Sidvall.Data.CopySettings settings)
        {
            var item = global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.Copy(this, settings);
            OnAfterCopy(item, settings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.FileSystemManager.Data.ISearchConfig item)
        {
            Import(item, null);
        }
        partial void OnAfterImport(global::Sidvall.FileSystemManager.Data.ISearchConfig source, Sidvall.Data.CopySettings settings);
        public void Import(global::Sidvall.FileSystemManager.Data.ISearchConfig item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.Import(this, item, settings);
            OnAfterImport(item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.ValidateAsync(this, context).ConfigureAwait(false);
            await ValidateAsync(context).ConfigureAwait(false);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync().ConfigureAwait(false);
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.SearchConfigManager.Initialize(this, settings);
        }

        #endregion
        
        #region ISearchConfig Members

        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.CaseSensitive
        {
            get
            {
                return this._CaseSensitive;
            }
            set
            {
                this._CaseSensitive = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.FileSearchPatterns
        {
            get
            {
                return this._FileSearchPatterns;
            }
            set
            {
                this._FileSearchPatterns = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.FolderPath
        {
            get
            {
                return this._FolderPath;
            }
            set
            {
                this._FolderPath = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.LoadDetails
        {
            get
            {
                return this._LoadDetails;
            }
            set
            {
                this._LoadDetails = value;
            }
        }
        System.Nullable<int> global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchConfigId
        {
            get
            {
                return this._SearchConfigId;
            }
            set
            {
                this._SearchConfigId = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFileContent
        {
            get
            {
                return this._SearchFileContent;
            }
            set
            {
                this._SearchFileContent = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFileName
        {
            get
            {
                return this._SearchFileName;
            }
            set
            {
                this._SearchFileName = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchFolderName
        {
            get
            {
                return this._SearchFolderName;
            }
            set
            {
                this._SearchFolderName = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ISearchConfig.SearchPatterns
        {
            get
            {
                return this._SearchPatterns;
            }
            set
            {
                this._SearchPatterns = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public SearchConfig()
        {
        }

        public SearchConfig(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}